home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / gawk-3.000 / gawk-3 / gawk-3.0.0 / awklib / eg / lib / assert.awk next >
Encoding:
Text File  |  1996-01-11  |  383 b   |  19 lines

  1. # assert --- assert that a condition is true. Otherwise exit.
  2. # Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
  3. # May, 1993
  4.  
  5. function assert(condition, string)
  6. {
  7.     if (! condition) {
  8.         printf("%s:%d: assertion failed: %s\n",
  9.             FILENAME, FNR, string) > "/dev/stderr"
  10.         _assert_exit = 1
  11.         exit 1
  12.     }
  13. }
  14.  
  15. END {
  16.     if (_assert_exit)
  17.         exit 1
  18. }
  19.